<!DOCTYPE html>
<html lang="en" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
	xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="/layui/css/layui.css">
<link rel="stylesheet" href="/css/custom.form.css">
</head>
<body>
	<div class="panel panel-default operation" hidden>
		<div class="panel-heading title"></div>
		<div class="layui-tab">
			<div class="layui-tab-content">
				<div class="layui-tab-item layui-show">
					<div class="layui-card-body">
						<form class="layui-form" action="" lay-filter="info">
							<input name="_tabKey" id="_tabKey" hidden>
							<input name="_jcajxxuuid" id="_jcajxxuuid" hidden>
							<input name="_logid" id="_logid" hidden>
							
							<div id="inspectionHearInfo">
								<fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
									<legend id="jcajbh"></legend>
								</fieldset>
								<div class="layui-form-item">
									<label class="layui-form-label">案件名称</label>
									<div class="layui-input-inline">
										<input type="text" id="ajmc" name="ajmc"
											class="layui-input layui-disabled" disabled="ture">
									</div>
									
									<label class="layui-form-label">检查项目</label>
									<div class="layui-input-inline">
										<input type="text" id="jcxm" name="jcxm"
											class="layui-input layui-disabled" disabled="ture">
									</div>
								</div>
								<div class="layui-form-item">	
									<label class="layui-form-label">检查人</label>
									<div class="layui-input-inline">
										<input type="text" id="jcry" name="jcry"
											class="layui-input layui-disabled" disabled="ture">
									</div>
								</div>
								<div class="layui-form-item">	
									<label class="layui-form-label">纳税人名称</label>
									<div class="layui-input-inline">
										<input type="text" id="nsrmc" name="nsrmc"
											class="layui-input layui-disabled" disabled="ture">
									</div>
									<label class="layui-form-label">纳税人识别号</label>
									<div class="layui-input-inline">
										<input type="text" id="nsrsbh" name="nsrsbh"
											class="layui-input layui-disabled" disabled="ture">
									</div>
								</div>
							
							</div>
								<div id="denoWorkDiv">						
							<fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
								<legend>完成工作</legend>
							</fieldset>
				
							<div class="layui-form-item">
								<div class="layui-input-block">
									<textarea disabled="ture" rows="2" name="content1" id="content1"
										placeholder="请输入反馈信息,1-500个字符" autocomplete="off"
										class="layui-textarea layui-disabled"
										onkeyup="javascript:texLength1(this, 'textarea_length1');"></textarea>
									<span class="red" id="textarea_length1">0</span> / <span
										class="num_count1">500</span>
								</div>
							</div>
								</div>					
							<div id="content2and3Div">
				
							</div>
							<div class="layui-form-item">
								<div class="layui-input-block">
									<!-- <button type="submit" class="layui-btn" id="saveWorkflowLog"
										onclick="return false" lay-submit lay-filter="saveWorkflowLog">提交</button> -->
									<button class="layui-btn layui-btn-primary" id="btn_cancel">返回</button>
								</div>
								
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>

	<div class="layui-tab table_div">
		<ul class="layui-tab-title">
			<li class="layui-this" id="dqr" >待确认</li>
			<li id="yqr" >已确认</li>
		</ul>
		
		<div class="layui-tab-content">
			<div class="layui-tab-item layui-show">
				<div id="searchParam" >
					<div class="layui-form-item">
					</div>
					<table class="layui-table" id="showTable" lay-filter="showTable"></table>
				</div>
			</div>

			<div class="layui-tab-item">
				<div id="searchParam" >
					<div class="layui-form-item">
					</div>
					<table class="layui-table" id="showTable1" lay-filter="showTable1"></table>
				</div>
			</div>
			
		</div>
		
		<!-- <div id="searchParam">
			<div class="layui-form-item">
				<div class="layui-input-inline">
					<input type="text" id="key" class="layui-input" autocomplete="off"
						placeholder="请输入">
				</div>

				<div class="layui-input-inline ">
					<button class="layui-btn" onclick="search()" id="search">查询</button>
				</div>
			</div>

		</div> -->
	</div>
	
	
	
<script type="text/html" id="toolbar">
  <div class="layui-btn-container">
    <button class="layui-btn layui-btn-sm" lay-event="batchConfirm">确认</button>
  </div>
</script>

<script type="text/html" id="tool">
  <a class="layui-btn layui-btn-xs" lay-event="confirm">确认</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="view">查看</a>
</script>

<script type="text/html" id="tool1">
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="view">查看</a>
</script>

</body>
</html>
<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script>
	//获取token
	var token = CoreUtil.getData("access_token");
	//地址栏转义token中的#号
	var tokenQuery = token.replace("#", "%23");
	var tableIns0;
	var tableIns1;
	var table = layui.table;
	var form = layui.form;
	var layer = layui.layer;
	var $ = jQuery = layui.jquery;
	var laydate = layui.laydate;

	layui.use([ 'table', 'layer', 'laydate' ],function() {
		//加载table
		tableIns0 = table.render({
			elem : '#showTable',
			contentType : 'application/json',
			headers : {
				"authorization" : token
			},
			page : true //开启分页
			,
			url : '/workflow/log/confirmList' //数据接口
			,
			method : 'POST',
			parseData : function(res) { //将原始数据解析成 table 组件所规定的数据
				return {
					"code" : res.code, //解析接口状态
					"msg" : res.msg, //解析提示文本
					"count" : CoreUtil.isEmpty(res.data) ? 0
							: res.data.total, //解析数据长度
					"data" : CoreUtil.isEmpty(res.data) ? null
							: res.data.records
				//解析数据列表
				}
			},
			cols : [ [ {
				type : 'checkbox',
				fixed : 'left'
			}, {
				field : 'id',
				title : '日志确认ID',
				sort : true,
				hide : false
			}, {
				field : 'logId',
				title : '日志ID',
				sort : true,
				hide : false
				
			}, {
				field : 'nsrmc',
				title : '纳税人名称',
				sort : true
			}, {
				field : 'nsrsbh',
				title : '纳税人识别号',
				sort : true
			}, {
				field : 'contentdate',
				title : '日志日期',
				sort : true
			}, {
				field : 'createTime',
				title : '创建时间',
				sort : true
			}, {
				field : 'createName',
				title : '日志创建人',
				sort : true
			}, {
				width : 120,
				toolbar : "#tool",
				title : '操作'
			} ] ],
			toolbar : '#toolbar'
		});

		//表头工具
		table.on('toolbar(showTable)',function(obj) {
			switch (obj.event) {
				case 'batchConfirm':
					var checkStatus = table.checkStatus(obj.config.id);
					var data = checkStatus.data;
					if (data.length == 0) {
						layer.msg("请选择要批量删除的列");
					} else {
						var ids = [];
						$(data).each(function(index,item) {
							ids.push(item.id);
						});
						tipDialog(ids);
					}
				break;
			};
		});
		//列操作
		table.on('tool(showTable)',function(obj) {
			var data = obj.data;
			switch (obj.event) {
				case 'confirm':
					var ids = [];
					ids.push(data.id);
					tipDialog(ids);
				break;
				case 'view':
					view(data);
				break;
			}
		});
		
		
		//加载table
		tableIns1 = table.render({
			elem : '#showTable1',
			contentType : 'application/json',
			headers : {
				"authorization" : token
			},
			page : true //开启分页
			,
			url : '/workflow/log/confirmList1' //数据接口
			,
			method : 'POST',
			parseData : function(res) { //将原始数据解析成 table 组件所规定的数据
				return {
					"code" : res.code, //解析接口状态
					"msg" : res.msg, //解析提示文本
					"count" : CoreUtil.isEmpty(res.data) ? 0
							: res.data.total, //解析数据长度
					"data" : CoreUtil.isEmpty(res.data) ? null
							: res.data.records
				//解析数据列表
				}
			},
			cols : [ [ {
				type : 'checkbox',
				fixed : 'left'
			}, {
				field : 'id',
				title : '日志确认ID',
				sort : true,
				hide : false
			}, {
				field : 'logId',
				title : '日志ID',
				sort : true,
				hide : false
				
			}, {
				field : 'nsrmc',
				title : '纳税人名称',
				sort : true
			}, {
				field : 'nsrsbh',
				title : '纳税人识别号',
				sort : true
			}, {
				field : 'contentdate',
				title : '日志日期',
				sort : true
			}, {
				field : 'createTime',
				title : '创建时间',
				sort : true
			}, {
				field : 'createName',
				title : '日志创建人',
				sort : true
			}, {
				width : 120,
				toolbar : "#tool1",
				title : '操作'
			} ] ],
			toolbar : '#toolbar1'
		});

		//列操作
		table.on('tool(showTable1)',function(obj) {
			var data = obj.data;
			switch (obj.event) {
				case 'view':
					view(data);
				break;
			}
		});
		
		
		// 确认
		var tipDialog = function(ids) {
			layer.open({
				content : "确定要确认么?",
				yes : function(index, layero) {
					layer.close(index); //如果设定了yes回调，需进行手工关闭
					CoreUtil.sendPost("/workflow/log/confirm", ids,
						function(res) {
							layer.msg(res.msg, {
								time : 1000
							}, function() {
								search();
							});
						});
				}
			});
		};

		//返回
		$("#btn_cancel").click(function() {
			$(".table_div").show();
			$(".operation").hide();
			return false;
		});

		//监听保存
		form.on('submit(submit)', function(data) {
			if (data.field.id === undefined
					|| data.field.id === null
					|| data.field.id === "") {
				CoreUtil.sendPost("/workflowLogConfirm/add",
						data.field, function(res) {
							$(".table_div").show();
							$(".operation").hide();
							search();
						});
			} else {
				CoreUtil.sendPut("/workflowLogConfirm/update",
						data.field, function(res) {
							$(".table_div").show();
							$(".operation").hide();
							search();
						});
			}

			return false;
		});
	});
	
	$("#dqr").click(function() {
		search();
	});

	$("#yqr").click(function() {
		search1();
	});
	
	
	//执行查询
	function search() {
		//这里以搜索为例
		tableIns0.reload({
			where : { //设定异步数据接口的额外参数，任意设
				key : $("#key").val()
			},
			page : {
				curr : 1
			//重新从第 1 页开始
			}
		});
	};
	
	
	//执行查询
	function search1() {
		//这里以搜索为例
		tableIns1.reload({
			where : { //设定异步数据接口的额外参数，任意设
				key : $("#key").val()
			},
			page : {
				curr : 1
			//重新从第 1 页开始
			}
		});
	};
	
	function view(data){
		
		var _id = data.logId;
		var _type = data.type;
		$("#content2and3Div").html("");
		$("#_logid").val(_id);
		var mapArr = {
			id : _id,
		};
		CoreUtil.sendPost("/workflow/log/view", mapArr, function(res) {
			if (res.code == '0') {
				$("#denoWorkDiv").hide();
				// 案卷日志
				var inspectionhearInfo = res.data[1];
				var _data = res.data[2];
				if(!CoreUtil.isEmpty(inspectionhearInfo)){
						
					$("#content2and3Div").show();
					$("#inspectionHearInfo").show();
					$("#jcajbh").html("案件编号：" + inspectionhearInfo.jcajbh);
					$("#_jcajxxuuid").val(inspectionhearInfo.jcajxxuuid);
					$("#ajmc").val(inspectionhearInfo.ajmc);
					$("#jcxm").val(inspectionhearInfo.jcxm);
					$("#nsrmc").val(inspectionhearInfo.nsrmc);
					$("#nsrsbh").val(inspectionhearInfo.nsrsbh);
					$("#jcry").val(inspectionhearInfo.jcry);
						
				}else{
					$("#content2and3Div").hide();
					$("#inspectionHearInfo").hide();
				}
				// 加载模板
				var viewSurveyTmp = "";
				for(var _i in _data){
					var _optionsConent = _data[_i].optionsFeedback;
					
					var _optionsTitle =_data[_i].optionsTitle;
					var _optionsType =_data[_i].optionsType;
					var _id =_data[_i].id;
					
					if(_optionsType == "1"){
						// 文本
						viewSurveyTmp += "<div class='layui-form-item'>"
							+"<label style='' class='layui-form-label'>" + _optionsTitle + "</label>"
					    	+"<div class='layui-input-block'>"
					    	+"<input disabled='ture' type='text' class='layui-unselect  layui-input "+_id+"' value='"+_optionsConent+"'>"
					    	+"</div>";
					    	
					}else if(_optionsType == "2"){
						var _contentSurveyJson = eval("(" + _optionsConent + ")");
						var l = Object.keys(_contentSurveyJson).length;
						// 多选
						viewSurveyTmp += "<div class='layui-form-item'>"
									+ "<label style='height: "+l*60+"px' class='layui-form-label'>" + _optionsTitle + "</label>";
						for (var _ii in _contentSurveyJson) {
							
							if(_contentSurveyJson[_ii].includes("_")){
								var _contentSurveyJsonArr = _contentSurveyJson[_ii].split("_");
								viewSurveyTmp += "<div onclick='optionsDuoxuan(this,"+_ii+")' class='layui-form-checked layui-unselect layui-form-checkbox "+_id+"' lay-skin='primary'><div></div><i class='layui-icon layui-icon-ok'></i></div>"+_contentSurveyJsonArr[0];
								if(!CoreUtil.isEmpty(_contentSurveyJsonArr[1])){
									viewSurveyTmp += "<input disabled='ture' style='width: 40%' type='text' class='layui-unselect layui-input "+_id+"_"+_ii+"' value='"+_contentSurveyJsonArr[1]+"'>";
								}
							
							}else{
								viewSurveyTmp += "<div onclick='optionsDuoxuan(this,"+_ii+")' class='layui-form-checked layui-unselect layui-form-checkbox "+_id+"' lay-skin='primary'><div></div><i class='layui-icon layui-icon-ok'></i></div>"+_contentSurveyJson[_ii];

							}
							
							viewSurveyTmp += "<br>";
							
						};
						
						viewSurveyTmp += "<hr>";
						
					}else if(_optionsType == "3"){
						// 单选
						viewSurveyTmp += "<div class='layui-form-item'>"
									+ "<label style='height: "+l*60+"px' class='layui-form-label'>" + _optionsTitle + "</label>";
						if(_optionsConent.includes("_")){
							var _contentSurveyJsonArr = _optionsConent.split("_");
							viewSurveyTmp += "<div onclick='optionsDanxuan(this,"+_ii+")' class='layui-form-radioed layui-unselect layui-form-radio "+_id+"'><i class='layui-anim layui-icon layui-icon-radio'></i><div>"+_contentSurveyJsonArr[0]+"</div></div>"
							if(!CoreUtil.isEmpty(_contentSurveyJsonArr[1])){
								viewSurveyTmp += "<input disabled='ture' style='width: 40%' type='text' class='layui-input layui-disabled "+_id+"_"+_ii+"' value='"+_contentSurveyJsonArr[1]+"'>";
							}
						}else{
							viewSurveyTmp += "<div onclick='optionsDanxuan(this,"+_ii+")' class='layui-form-radioed layui-unselect layui-form-radio "+_id+"'><i class='layui-anim layui-icon layui-icon-radio'></i><div>"+_optionsConent+"</div></div>"
						}
									
						
						
						viewSurveyTmp += "<br>";
						viewSurveyTmp += "<hr>";
						
					}
				}
				$("#content2and3Div").html(viewSurveyTmp);
				
				$(".operation").show();
				$(".table_div").hide();

			} else {
				layer.msg(res.msg);
				return false;
				
			}
		});
	}
	
</script>